&lt;!--- 
	/* ******************************************************************************************************************************
	 * This class is provided as a convenience parent class
	 * use this for tasks that are common across all controllers
	 * for e.g. methods like authenticate() , and login(), logout() can go here
	 *
	 * They will always be inherited by all controllers
	 * Child controller can then provide/deny access to their methods (for e.g. authenticated users 
	 * can access specific_controller.create() method)
	 * ******************************************************************************************************************************
	 */
---&gt;
&lt;cfcomponent&gt;
	&lt;cfset this.modelfactory = createObject('component',"#application.env.component_location#.app.model.model_factory").init() /&gt;
	
	&lt;!--- function takes a query object and returns json ---&gt;
	&lt;cffunction access="package" returntype="void" name="json"&gt;
		&lt;cfargument name="fnReturn" type="query" /&gt;
		
		&lt;cfset json_string = serializeJSON(arguments.fnReturn) /&gt;
		&lt;cfsetting enablecfoutputonly="true" showdebugoutput="false" /&gt;
		&lt;cfheader name="Content-Disposition" value="attachment;filename=#request.controller#.json" /&gt;
		&lt;cfcontent type="text/json" variable="#toBinary(toBase64(json_string))#"/&gt;
	&lt;/cffunction&gt;
	&lt;cffunction access="package" returntype="void" name="xml"&gt;
		&lt;cfargument name="fnReturn" /&gt;
		&lt;cfsetting enablecfoutputonly="true" showdebugoutput="false" /&gt;
		&lt;cfset qry = arguments.fnReturn /&gt;
		&lt;cfoutput&gt;
		&lt;cfsavecontent variable="return_xml"&gt;
			&lt;data&gt;
				&lt;metadata&gt;
					&lt;recordcount&gt;#arguments.fnReturn.recordcount#&lt;/recordcount&gt;
				&lt;/metadata&gt;
				&lt;cfloop query="qry"&gt;
				&lt;row id="#currentrow#"&gt;
					&lt;cfloop list="#arguments.fnReturn.columnlist#" index="i"&gt;
						&lt;cfset col_value = arguments.fnReturn["#i#"] /&gt;
						&lt;#i#&gt;
							#trim(col_value)#
						&lt;/#i#&gt;
					&lt;/cfloop&gt;
				&lt;/row&gt;	
			&lt;/cfloop&gt;
			&lt;/data&gt;
		&lt;/cfsavecontent&gt;
		&lt;/cfoutput&gt;
		&lt;cfheader name="Content-Disposition" value="attachment;filename=#request.controller#.xml" /&gt;
		&lt;cfcontent type="text/json" variable="#toBinary(toBase64(return_xml))#"/&gt;
	&lt;/cffunction&gt;
&lt;/cfcomponent&gt;
